package com.iflytek.uc.authentication.handler.impl;

import org.apache.commons.lang.StringUtils;

import com.iflytek.uc.authentication.handler.AuthenticationHandler;
import com.iflytek.uc.authentication.handler.PasswordEncoder;
import com.iflytek.uc.domain.Account;

public class StandardAuthenticationHandler implements AuthenticationHandler {

	private PasswordEncoder passwordEncoder;
	
	public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
		this.passwordEncoder = passwordEncoder;
	}

	public boolean authenticate(Account account, String password) {
		String encodedPassword = passwordEncoder.encode(account.getName(), password);
		return StringUtils.equals(account.getPassword(), encodedPassword);
	}

}
